
package py.una.pol.raphapy.autoventas.model;

import java.io.Serializable;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Rafael E. Benegas
 */
@Entity
@Table(name = "movimiento_mercaderia")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "MovimientoMercaderia.findAll", query = "SELECT m FROM MovimientoMercaderia m"),
    @NamedQuery(name = "MovimientoMercaderia.findByCodMovMer", query = "SELECT m FROM MovimientoMercaderia m WHERE m.codMovMer = :codMovMer"),
    @NamedQuery(name = "MovimientoMercaderia.findByFecMovMer", query = "SELECT m FROM MovimientoMercaderia m WHERE m.fecMovMer = :fecMovMer"),
    @NamedQuery(name = "MovimientoMercaderia.findByCanMovMer", query = "SELECT m FROM MovimientoMercaderia m WHERE m.canMovMer = :canMovMer")})
public class MovimientoMercaderia implements Serializable {
    private static final long serialVersionUID = 1L;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "cod_mov_mer")
    private BigDecimal codMovMer;
    @Basic(optional = false)
    @NotNull
    @Column(name = "fec_mov_mer")
    @Temporal(TemporalType.TIMESTAMP)
    private Date fecMovMer;
    @Basic(optional = false)
    @NotNull
    @Column(name = "can_mov_mer")
    private BigInteger canMovMer;
    @JoinTable(name = "detalle_venta_mercaderia", joinColumns = {
        @JoinColumn(name = "cod_mov_mer", referencedColumnName = "cod_mov_mer")}, inverseJoinColumns = {
        @JoinColumn(name = "cod_ven_ven", referencedColumnName = "cod_ven_ven")})
    @ManyToMany
    private Collection<VentaMercaderia> ventaMercaderiaCollection;
    @JoinColumn(name = "cod_mer", referencedColumnName = "cod_mer")
    @ManyToOne(optional = false)
    private Mercaderia codMer;

    public MovimientoMercaderia() {
    }

    public MovimientoMercaderia(BigDecimal codMovMer) {
        this.codMovMer = codMovMer;
    }

    public MovimientoMercaderia(BigDecimal codMovMer, Date fecMovMer, BigInteger canMovMer) {
        this.codMovMer = codMovMer;
        this.fecMovMer = fecMovMer;
        this.canMovMer = canMovMer;
    }

    public BigDecimal getCodMovMer() {
        return codMovMer;
    }

    public void setCodMovMer(BigDecimal codMovMer) {
        this.codMovMer = codMovMer;
    }

    public Date getFecMovMer() {
        return fecMovMer;
    }

    public void setFecMovMer(Date fecMovMer) {
        this.fecMovMer = fecMovMer;
    }

    public BigInteger getCanMovMer() {
        return canMovMer;
    }

    public void setCanMovMer(BigInteger canMovMer) {
        this.canMovMer = canMovMer;
    }

    @XmlTransient
    public Collection<VentaMercaderia> getVentaMercaderiaCollection() {
        return ventaMercaderiaCollection;
    }

    public void setVentaMercaderiaCollection(Collection<VentaMercaderia> ventaMercaderiaCollection) {
        this.ventaMercaderiaCollection = ventaMercaderiaCollection;
    }

    public Mercaderia getCodMer() {
        return codMer;
    }

    public void setCodMer(Mercaderia codMer) {
        this.codMer = codMer;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (codMovMer != null ? codMovMer.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        
        if (!(object instanceof MovimientoMercaderia)) {
            return false;
        }
        MovimientoMercaderia other = (MovimientoMercaderia) object;
        if ((this.codMovMer == null && other.codMovMer != null) || (this.codMovMer != null && !this.codMovMer.equals(other.codMovMer))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "py.una.pol.raphapy.autoventas.model.MovimientoMercaderia[ codMovMer=" + codMovMer + " ]";
    }
    
}
